//
//  EmoticonAttachment.swift
//  SinaWebo
//
//  Created by mis on 16/3/23.
//  Copyright © 2016年 mis. All rights reserved.
//

import UIKit

class EmoticonAttachment: NSTextAttachment {
    
    var chs: String?
    
    func emoticonimageText(emoticon: Emoticon, font: UIFont) -> NSAttributedString {
        image = UIImage(contentsOfFile: emoticon.imagePath ?? "")
        chs = emoticon.chs
        let height = font.lineHeight
        bounds = CGRect(x: 0, y: -4, width: height, height: height)
        let imageText = NSMutableAttributedString(attributedString: NSAttributedString(attachment: self))
        imageText.addAttribute(NSFontAttributeName, value: font, range: NSMakeRange(0, 1))
        return imageText
    }
}
